package com.so206.utils;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * 时间转换
 */
public class DateUtils {

    public static SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");

    private Date start_time;

    private Date end_time;

    public Date getStart_time() {
        return start_time;
    }

    public void setStart_time(Date start_time) {
        this.start_time = start_time;
    }

    public Date getEnd_time() {
        return end_time;
    }

    public void setEnd_time(Date end_time) {
        this.end_time = end_time;
    }

    /**
     * 获得当天0:00时间
     */
    public Date getStartTime() {
        if (start_time == null) {
            return null;
        }
        Calendar cal = Calendar.getInstance();
        cal.setTime(start_time);
        cal.set(Calendar.HOUR_OF_DAY, 0);
        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MILLISECOND, 0);
        return cal.getTime();
    }

    /**
     * 获得第二天 0:00 时间
     */
    public Date getEndTime() {
        if (end_time == null) {
            return null;
        }
        Calendar cal = Calendar.getInstance();
        cal.setTime(end_time);
        cal.set(Calendar.HOUR_OF_DAY, 0);
        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MILLISECOND, 0);
        cal.add(Calendar.DATE, 1);
        return cal.getTime();
    }

}
